<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/    
//打印sql语句
// Event::listen('illuminate.query',function($query){
//     var_dump($query);
// });

Route::group(array('namespace' => 'desktop', 'prefix' => '/'), function() {
    Route::get('/', 'DefaultController@index');
    Route::get('/articles/{articleId}', 'ArticleController@show');
    Route::get('/galleries', 'GalleryController@index');
    Route::get('/galleries/{galleryId}', 'GalleryController@show');
    Route::get('/galleries/{galleryId}/img/{imgId}', 'GalleryController@img');
    Route::get('/articles', 'ArticleController@index');
	Route::get('/pages/{slug}', 'PageController@index');    
    
    
    Route::get('/mylove', 'MyloveController@index');
});

Route::group(array('namespace' => 'backend', 'prefix' => 'backend'), function() {
    Route::get('/login', 'LoginController@login');
    Route::post('/login', 'LoginController@attempt');
    Route::get('/logout', 'LoginController@logout');
});

Route::group(array('namespace' => 'backend', 'prefix' => 'backend', 'middleware' => 'auth'), function() {
    Route::model('articles', '\MyBlog\Models\Article');
    Route::model('categories', '\MyBlog\Models\Category');
    Route::model('members', '\MyBlog\Models\Member');
    Route::model('galleries', '\MyBlog\Models\Gallery');
    
    Route::get('/', 'DefaultController@index');
    Route::get('/index', 'DefaultController@index');
    
    Route::resource('articles', 'ArticleController');
    Route::post('articles/{articles}/change-state', 'ArticleController@changeState');
    
    Route::resource('categories', 'CategoryController');
    Route::post('categories/{categories}/change-state', 'CategoryController@changeState');
    
    Route::resource('members', 'MemberController', array('only' => 'index'));
    
    Route::resource('galleries', 'GalleryController');
    
    Route::resource('galleries.imgs', 'GalleryImgController');
    
    Route::get('tags', 'TagController@index');
});
